<template>
  <el-dialog :title="title" :visible.sync="dialogFormVisible">
    <el-form ref="userInfo" :model="form" :rules="rule">
      <el-form-item label="用户密码" :label-width="formLabelWidth" prop="user_pass_word">
        <el-input v-model="form.user_pass_word" autocomplete="off" type="password" />
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="dialogFormVisible = false">取 消</el-button>
      <el-button type="primary" @click="submit('userInfo')">确 定</el-button>
    </div>
  </el-dialog>

</template>

<script>
import { operationSacanningGunUsersApi } from '@/api/system'
export default {
  data() {
    return {
      dialogFormVisible: false,
      form: {
        id: '',
        user_pass_word: ''
      },
      rule: {
        user_pass_word: [
          { required: true, message: '请填写用户密码', trigger: 'blur' }
        ]
      },
      formLabelWidth: '120px',
      title: '重置密码'
    }
  },
  methods: {
    submit(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          const data = {
            type: 2,
            pro: this.form
          }
          console.log(data)
          operationSacanningGunUsersApi(data).then(res => {
            // console.log('submit', res)
            if (res.code === 200) {
              this.$message.success('信息提交成功！')
              this.dialogFormVisible = false
              this.$emit('reloadFun')
              this.form = {
                id: '',
                user_pass_word: ''
              }
            }
          })
        } else {
          this.$message.warning('信息提交失败！请重新提交！')
          return false
        }
      })
    }
  }

}
</script>

<style lang="sass" scoped>

</style>
